include $(TOPDIR)/rules.mk

PKG_NAME:=compose_lede
PKG_SRC_NAME:=compose

PKG_VERSION:=2.40.0
PKG_RELEASE:=1
PKG_LICENSE:=Apache-2.0
PKG_LICENSE_FILES:=LICENSE

PKG_SOURCE:=$(PKG_SRC_NAME)-v$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=https://codeload.github.com/docker/compose/tar.gz/v${PKG_VERSION}?
PKG_HASH:=4b4a0989ac393f7c2bdacda565a167ee0c7347fb20d1e6110477ad4d18b28a02

PKG_MAINTAINER:=Javier Marcet <javier@marcet.info>

PKG_CONFIG_DEPENDS:= \
	CONFIG_DOCKER_COMPOSE_LEDE_COMPRESS_GOPROXY 
	
PKG_BUILD_DEPENDS:=golang/host
PKG_BUILD_PARALLEL:=1
PKG_BUILD_FLAGS:=no-mips16

PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_SRC_NAME)-$(PKG_VERSION)

GO_PKG:=github.com/docker/compose/v2
GO_PKG_BUILD_PKG:=github.com/docker/compose/v2/cmd
GO_PKG_LDFLAGS_X:=github.com/docker/compose/v2/internal.Version=v$(PKG_VERSION)
GO_PKG_TAGS:=e2e,kube

include $(INCLUDE_DIR)/package.mk
include $(TOPDIR)/feeds/packages/lang/golang/golang-package.mk

define Package/docker-compose_lede
  SECTION:=utils
  CATEGORY:=Utilities
  TITLE:=(LEDE) Docker Lede Compose
  URL:=https://github.com/docker/compose
  DEPENDS:=$(GO_ARCH_DEPENDS) +docker_lede
endef

define Package/docker-compose_lede/description
  Multi-container orchestration for Docker
endef

define Package/docker-compose_lede/config
  config DOCKER_COMPOSE_LEDE_COMPRESS_GOPROXY
	bool "Compiling with GOPROXY proxy"
	default y
endef

ifeq ($(CONFIG_DOCKER_COMPOSE_LEDE_COMPRESS_GOPROXY),y)
export GO111MODULE=on
export GOPROXY=https://goproxy.cn,direct
endif

define Package/docker-compose_lede/install
	$(INSTALL_DIR) $(1)/usr/lib/docker/cli-plugins/
	$(INSTALL_BIN) $(GO_PKG_BUILD_BIN_DIR)/cmd $(1)/usr/lib/docker/cli-plugins/docker-compose
	$(INSTALL_DIR) $(1)/usr/bin/
	$(LN) ../lib/docker/cli-plugins/docker-compose $(1)/usr/bin/docker-compose
endef

$(eval $(call GoBinPackage,docker-compose_lede))
$(eval $(call BuildPackage,docker-compose_lede))

